﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using SmartCity.BasicData.Api.Application.Commond.ADepartMent;
using SmartCity.BasicData.Api.Application.Commond.DepartMent;
using SmartCity.BasicData.Common;

namespace SmartCity.BasicData.Api.Controllers
{
    /// <summary>
    /// 部门控制器-API
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class DepartMentController : ControllerBase
    {
        /// <summary>
        /// 中介者组件的字段
        /// </summary>
        private readonly IMediator mediator;
        /// <summary>
        /// 通过构造函数注入中介者
        /// </summary>
        /// <param name="mediator"></param>
        public DepartMentController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        ///// <summary>
        ///// 获取部门树形数据结构
        ///// </summary>
        ///// <returns></returns>
        //[HttpGet]
        //public Task<ApiResult< List<DepartMentDTO>>> GetDepartmentTree() {
        //    GetDepartMentCommand command = new GetDepartMentCommand();
        //    return mediator.Send(command);
        //}
        /// <summary>
        /// 获取部门级联数据
        /// </summary>
        /// <returns></returns>
        //[HttpGet]
        //public Task<ApiResult<IList<ADepartMentDTO>>> GetDepartmentJL() { 
        //  GetDepartmentCommand command = new GetDepartmentCommand();
        //    return mediator.Send(command);
        //}



        
        [HttpGet]
        public Task<ApiResult<List<DepartMentTreeDTO>>> GetTree() {
            return   mediator.Send(new GetDepartmentTreeCommand());
        }
    }
}
